#include <pvm3.h>

#include "job.h"
#include <string.h>


#define MAX_JOB 400

/* Fonction qui renvoi un job a effectue. */

struct job * get_job(unsigned long max)
{
  static int current_job = 1;
  if (current_job == MAX_JOB)
    {
      printf("no more jobs");
      return NULL;
    }
  else
    {
      struct job * new_job = malloc(sizeof(struct job));
      new_job->init = current_job*max/400;
      new_job->end = (current_job+1)*max/400;
      current_job++;
      return new_job;
    }
} 



int main(int argc,char*argv[])
{
  if(argc < 3){
    printf("expected slave_nbr|password|size_max");
}
  int nb_slave = atoi(argv[1]);
  int size_max = atoi(argv[3]);
  int tids[nb_slave];
  char **arg;
  strcpy(arg[0], argv[2]);
  arg[1]=NULL;
  pvm_spawn("slave", arg, 0, "", nb_slave, tids);
  
  //

  return EXIT_SUCCESS;
  
}


